home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / ltp_fixextralabel.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  83 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <dos/dos.h>    /* For AmigaDOS error definitions */
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. /*****************************************************************************/
  23.  
  24. #ifdef DO_MENUS    /* Support code */
  25.  
  26.     /* LTP_FixExtraLabel(RootMenu *Root,LONG *Error):
  27.      *
  28.      *    Fix up the submenu indicators and command labels.
  29.      */
  30.  
  31. VOID
  32. LTP_FixExtraLabel(RootMenu *Root,LONG *ErrorPtr)
  33. {
  34.     ItemNode    *Item;
  35.     LONG         Error = 0;
  36.  
  37.         // Now take care of items which have command sequences
  38.         // or submenu items attached
  39.  
  40.     for(Item = (ItemNode *)Root->ItemList.mlh_Head ; !Error && Item->Node.mln_Succ ; Item = (ItemNode *)Item->Node.mln_Succ)
  41.     {
  42.             // Does this one need more label data?
  43.  
  44.         if(Item->Flags & (ITEMF_HasSub | ITEMF_Command))
  45.         {
  46.             struct IntuiText *IntuiText;
  47.  
  48.             DB(kprintf("  attach to |%s|\n",((struct IntuiText *)Item->Item.ItemFill)->IText));
  49.  
  50.                 // Make room for the extra label data
  51.  
  52.             if(IntuiText = AsmAllocPooled(Root->Pool,sizeof(struct IntuiText),SysBase))
  53.             {
  54.                     // Fill it in
  55.  
  56.                 LTP_InitIText(Root,IntuiText);
  57.  
  58.                     // Command sequence?
  59.  
  60.                 if(Item->ExtraLabel)
  61.                 {
  62.                     IntuiText->IText        = Item->ExtraLabel;
  63.                     IntuiText->ITextFont    = (struct TextAttr *)&Root->BoldAttr;
  64.                 }
  65.                 else
  66.                     IntuiText->IText = (STRPTR)"»";
  67.  
  68.                 IntuiText->TopEdge = (Root->ItemHeight - Root->RPort.TxHeight) / 2;;
  69.  
  70.                     // Link to previous entry
  71.  
  72.                 ((struct IntuiText *)Item->Item.ItemFill)->NextText = IntuiText;
  73.             }
  74.             else
  75.                 Error = ERROR_NO_FREE_STORE;
  76.         }
  77.     }
  78.  
  79.     *ErrorPtr = Error;
  80. }
  81.  
  82. #endif    /* DO_MENUS */
  83.